 
 $(document).ready(function(){
 	$("#cust_name").focus(function(){
 		//alert("dfjd");
 		$(this).css('color','black');
 	});
 	
 	$("#father_name").focus(function(){
 		//alert("dfjd");
 		$(this).css('color','black');
 	});
 	
 	$("#poi_num1").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#poi_num2").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#doc_addr_num").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#doc_addr_cross").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#alt_num").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#alt_cross").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#ref_name").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#ref_ph").focus(function(){
 		$(this).css('color','black');
 	});
 	
 	$("#loc_addr_num").focus(function(){
 		$(this).css('color','black');
 	});
 	 	
 	
 });
 
 $(window).load(function () {
        $("#retailer_name").focus();
  /*
        $("#quick_entry").click(function(){
           
          var sl_no = $('input[name="sl_num"]').val();
       $.ajax({
      type: "GET",
      url: "/caf/get_batchdetails/"+ sl_no,
      
      dataType: "json",
      success: function(value){ 
       
          $('input[name="mobile_num"]').attr('value',value.mobile); 
          $('input[name="sim_no"]').attr('value',value.sim_num); 
          $('input[name="batch_id"]').attr('value',value.batch_id);
        
      }

        });

        });
    */
    
  });
  
  //for quick entry...
  


//this combo for document address city
	(function( $ ) {
		$.widget( "ui.combobox_doc_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=doc_city_input name=doc_city size=16>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#doc_city" ).combobox_doc_city();
	});
	



$(document).ready(function(){
	   		$(".autobox").autobox();
			});


			
$(function() {
		$( "input:submit, input:reset", "#div_entry" ).button();
		$( "a", "#div_entry" ).click(function() { return false; });
		});
// we need six different combo box..so six different combo code....we can't reuse single combo box...
//this combo for city name...
(function( $ ) {
		$.widget( "ui.combobox_loc_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_city name=loc_city_name size=16 />" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_city" ).combobox_loc_city();
		
	});
//this combo for alternate address city
	(function( $ ) {
		$.widget( "ui.combobox_alt_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=alt_city_input name=alt_city size=16>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#alt_city" ).combobox_alt_city();
		
	});
	

//this combo box is to display area dropdown in local reference field...
	(function( $ ) {
		$.widget( "ui.combobox_loc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_area name=loc_area size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_area" ).combobox_loc_area();
	});

//this combo box is to display area dropdown in alternate field...
	(function( $ ) {
		$.widget( "ui.combobox_alt_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=alt_area name=alt_area size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#alt_area" ).combobox_alt_area();
	});

//this combo box is to display area dropdown in local reference field...
	(function( $ ) {
		$.widget( "ui.combobox_loc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_area name=loc_area size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_area" ).combobox_loc_area();
	});

//this combo box is to display area dropdown in document field...
	(function( $ ) {
		$.widget( "ui.combobox_doc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=doc_area name=doc_area size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#doc_area" ).combobox_doc_area();
	});

	
//to display city names when state name changed in document address
		$(document).ready(function(){
			$("#doc_state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/doc_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#document_city").html(html);   
							
							$(function() {
						$( "#doc_city" ).combobox_doc_city();
					});
						  }
			

			  });

			});
			});
			
	//to display alternate city dropdown list....		
	$(document).ready(function(){
			$("#alt_state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/alt_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#alternate_city").html(html); 
						$(function() {
						$( "#alt_city" ).combobox_alt_city();
		
	});
			    }

			  });

			});
			});
			
//this is to display cities information in local reference	
	$(document).ready(function(){
			$("#loc_state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/loc_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_refer_city").html(html); 
			
		$(function() {
		$( "#loc_city" ).combobox_loc_city();
		
	});
			    }

			  });

			});
			});
//to display areas for document address field....


$(document).ready(function(){
	$('#document_city').focusout(function(){
	var src = $('#doc_city').val();
	
		$.ajax({
			type: "GET",
			url: "/caf/doc_display_areas/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_doc_area").html(html); 
			
		$(function() {
		$( "#doc_area" ).combobox_doc_area();
			});
			    }

			  });
	});	
	//to place pincode in document address field...
	$(document).ready(function(){
		$('#span_doc_area').focusout(function(){
			var src = $('#doc_area').val();	
						
			$.ajax({
			type: "GET",
			url: "/caf/doc_display_pin/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_doc_pin").html(html); 
			
			    }

			  });
			
		});
	});
			
//to display areas for alternate address field....

$(document).ready(function(){
	$('#alternate_city').focusout(function(){
	var src = $('#alt_city').val();
		
		
		$.ajax({
			type: "GET",
			url: "/caf/alt_display_areas/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_alt_area").html(html); 
			
		$(function() {
		$( "#alt_area" ).combobox_alt_area();
			});
			    }

			  });
		
		
		});
	});	
	//to place pincode in alternate address field...
	$(document).ready(function(){
		$('#span_alt_area').focusout(function(){
			var src = $('#alt_area').val();	
						
			$.ajax({
			type: "GET",
			url: "/caf/alt_display_pin/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_alt_pin").html(html); 
			
			    }

			  });
			
		});
	});
	

//to display areas for local reference address field....
	$(document).ready(function(){
	$('#span_refer_city').focusout(function(){
	var src = $('#loc_city').val();
		
		
		$.ajax({
			type: "GET",
			url: "/caf/loc_display_areas/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_loc_area").html(html); 
			
		$(function() {
		$( "#loc_area" ).combobox_loc_area();
			});
			    }

			  });
		
		
		});
	});
	
	//to place pincode in local address field...
	$(document).ready(function(){
		$('#span_loc_area').focusout(function(){
			var src = $('#loc_area').val();	
						
			$.ajax({
			type: "GET",
			url: "/caf/loc_display_pin/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_loc_pin").html(html); 
			
			    }

			  });
			
		});
	});
	
	});
		
	/*
			
//validating fields value for numbers only in pincode field
$(document).ready(function(){
$("#alt_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

$("#loc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

$("#doc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

});
//work is pending here...

		
//checking for local reference field's set or not...
$(document).ready(function(){
	$("#loc_pin").blur(function(){	
	var loc_val = $(this).val();
	if(loc_val !="")
	{
		var loc_area = $("#loc_area").val();
		var loc_city = $("#loc_city").val();		
		var loc_addr_cross = $("#loc_addr_cross").val();
		var loc_addr_num = $("#loc_addr_num").val();
		
		
		if(loc_addr_num=="Door No/Flat No/House No" || loc_addr_cross=="Cross,Main Stage,Block")
		{
			alert("Please enter address field!");
			return false;
		}
		
		if(loc_area=="" || loc_city == null || loc_addr_cross == "" || loc_addr_num == "")
		{
			alert("Please enter address field!");
			return false;
		}	
		
		
	}
	});

});

*/



$(document).ready(function(){
	
	
  $("#same_loc").click(function(){
	if ($('#same_loc').is(':checked')) { 
	
	var doc_addr_num = $("#doc_addr_num").val();
	var doc_addr_cross = $("#doc_addr_cross").val();
	var doc_state = $("#doc_state_name").val();
	
	var city_id = $('select[name="doc_city_name"]').val();
	var city_name = $('input[name="doc_city"]').val();
	var area_name = $('select[name="doc_area_name"]').val();
	var area_id = $('input[name="doc_area"]').val();
	var pincode = $('input[name="doc_pincode"]').val();
	
	
	
	//var doc_city_name = $("#doc_city_input").val();
	//var doc_city_id = $("#doc_city").val();
  //var doc_area_name = $("#doc_area").val();
  //var doc_pincode = $("#doc_pin").val();
	
	$("#alt_num").attr('value',doc_addr_num);
	$("#alt_cross").attr('value',doc_addr_cross);
	$("#alt_state_name").attr('value',doc_state);
	$('select[name="alt_city_name"]').attr('value',city_id);
	$('input[name="alt_city"]').attr('value',city_name);
	$('select[name="alt_area_name"]').attr('value',area_name);
	$('input[name="alt_area"]').attr('value',area_id);
	$('input[name="alt_pincode"]').attr('value',pincode);

	
		 } else {
	 
	 $("#alt_num").attr('value','Door No/Flat No/House No');
	 $("#alt_cross").attr('value','Cross,Main Stage,Block');
	 $("#alt_state_name").attr('value',' '); 
	 $('select[name="alt_city_name"]').attr('value',' ');
	 $('select[name="alt_area_name"]').attr('value',' ');
	 $('input[name="alt_pincode"]').attr('value',' ');
	 $('input[name="alt_area"]').attr('value',' ');
	 $('input[name="alt_city"]').attr('value',' ');
	  }
    
  });
});
